package com.tid.hbasees.utils.kafka;


import com.tid.hbasees.SysConfig;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class KafkaHelper {

    @Resource(name = "sysConfig")
    private SysConfig sysConfig;

    private ExecutorService pool;

    @PostConstruct
    public void init() {
        this.pool = Executors.newFixedThreadPool(sysConfig.getKafkaConsumerCount());
        for (int i = 0; i < sysConfig.getKafkaConsumerCount(); i++) {
            pool.submit(new Consumer(sysConfig));
        }
    }
}